<?php
namespace Common\Model;
use Think\Model;

class GuestBookModel extends Model {
	private $_db ='';
	public function __construct(){
		$this->_db = M('guestbook');
	}
	
	public function getGuestBook ($data,$page,$pageSize) {
		$offset = ($page-1)*$pageSize;
		$list = $this->_db->where($data)->order('id desc')->limit($offset,$pageSize)->select();
	    return $list;
	}
	public function getGuestBookCount ($data){
		$data['status']=array('neq',-1);
		return $this->_db->where($data)->count();
	}
	
	public function updataStatusById ($id,$status){
		if(!is_numeric($id) || !$id){
			throw_exception("ID不合法");
		}
		if(!is_numeric($status) || !$status){
			throw_exception("状态不合法");
		}
		$data['status']=$status;
		return $this->_db->where('id='.$id)->save($data);
	}
}	